<?php

class application_LoginForm extends Zend_Form{
public $adresse;
public $password;
public function init(){
    $this->setName('authentification')
        ->setAction('valider')
        ->setMethod('post');
    $emptyValidator = new Zend_Validate_NotEmpty();
    $emptyValidator->setMessage(("All the fields are required"));
    $emailValidator = new Zend_Validate_EmailAddress();
    $emailValidator->setMessage(('E-mail must be a valid'));
    $primaryValidator = new Zend_Validate_Db_NoRecordExists('Profiles', 'Email');
    $primaryValidator->setMessage(("E-mail adress already in use"), Zend_Validate_Db_Abstract::ERROR_RECORD_FOUND);
    $stringLengthValdiator = new Zend_Validate_StringLength(6, 12);
    $stringLengthValdiator->setMessage(('Password must have 6 to 12 caracters'));
    $this->adresse = new Zend_Form_Element_Text('email');
    $this->adresse
              ->setLabel(('Email'))
              ->setAttrib('size', 40)
              ->setAttrib('class', 'inputbox required')
              ->setAttrib('maxlength', 50)
              ->setAttrib('id', 'email')
              ->setRequired(true)
              ->addFilter('StripTags')
              ->addFilter('StringTrim')
              ->addValidator($emptyValidator)
              ->addValidator(new Zend_Validate_Alnum());
                 // pour le mot de passe
    $this->password = new Zend_Form_Element_Password('password');
    $this->password ->setLabel(('Password'))
              ->setAttrib('size', 40)
              ->setAttrib('class', 'inputbox required validate-password')
              ->setAttrib('maxlength', 100)
              ->setAttrib('id', 'password')
              ->setRequired(true)
              ->addValidator($emptyValidator);
    $submit = new Zend_Form_Element_Submit('valider');
        $submit->setAttrib('class', 'button validate')
        ->setLabel(('Valider'));
     $this->addElements(array($this->adresse, $this->password,$submit));
  }
}
?>